/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package EA_Model.IEC61970.OperationalLimits.impl;

import EA_Model.IEC61970.Domain.Seconds;

import EA_Model.IEC61970.OperationalLimits.OperationalLimitDirectionKind;
import EA_Model.IEC61970.OperationalLimits.OperationalLimitType;
import EA_Model.IEC61970.OperationalLimits.OperationalLimitsPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Operational Limit Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link EA_Model.IEC61970.OperationalLimits.impl.OperationalLimitTypeImpl#getAcceptableDuration <em>Acceptable Duration</em>}</li>
 *   <li>{@link EA_Model.IEC61970.OperationalLimits.impl.OperationalLimitTypeImpl#getDirection <em>Direction</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class OperationalLimitTypeImpl extends EObjectImpl implements OperationalLimitType {
	/**
	 * The cached value of the '{@link #getAcceptableDuration() <em>Acceptable Duration</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAcceptableDuration()
	 * @generated
	 * @ordered
	 */
	protected Seconds acceptableDuration;

	/**
	 * The default value of the '{@link #getDirection() <em>Direction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDirection()
	 * @generated
	 * @ordered
	 */
	protected static final OperationalLimitDirectionKind DIRECTION_EDEFAULT = OperationalLimitDirectionKind.HIGH;

	/**
	 * The cached value of the '{@link #getDirection() <em>Direction</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDirection()
	 * @generated
	 * @ordered
	 */
	protected OperationalLimitDirectionKind direction = DIRECTION_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected OperationalLimitTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OperationalLimitsPackage.Literals.OPERATIONAL_LIMIT_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Seconds getAcceptableDuration() {
		if (acceptableDuration != null && acceptableDuration.eIsProxy()) {
			InternalEObject oldAcceptableDuration = (InternalEObject)acceptableDuration;
			acceptableDuration = (Seconds)eResolveProxy(oldAcceptableDuration);
			if (acceptableDuration != oldAcceptableDuration) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION, oldAcceptableDuration, acceptableDuration));
			}
		}
		return acceptableDuration;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Seconds basicGetAcceptableDuration() {
		return acceptableDuration;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setAcceptableDuration(Seconds newAcceptableDuration) {
		Seconds oldAcceptableDuration = acceptableDuration;
		acceptableDuration = newAcceptableDuration;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION, oldAcceptableDuration, acceptableDuration));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OperationalLimitDirectionKind getDirection() {
		return direction;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDirection(OperationalLimitDirectionKind newDirection) {
		OperationalLimitDirectionKind oldDirection = direction;
		direction = newDirection == null ? DIRECTION_EDEFAULT : newDirection;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__DIRECTION, oldDirection, direction));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION:
				if (resolve) return getAcceptableDuration();
				return basicGetAcceptableDuration();
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__DIRECTION:
				return getDirection();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION:
				setAcceptableDuration((Seconds)newValue);
				return;
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__DIRECTION:
				setDirection((OperationalLimitDirectionKind)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION:
				setAcceptableDuration((Seconds)null);
				return;
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__DIRECTION:
				setDirection(DIRECTION_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__ACCEPTABLE_DURATION:
				return acceptableDuration != null;
			case OperationalLimitsPackage.OPERATIONAL_LIMIT_TYPE__DIRECTION:
				return direction != DIRECTION_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (direction: ");
		result.append(direction);
		result.append(')');
		return result.toString();
	}

} //OperationalLimitTypeImpl
